﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Xml;

namespace SPVisualDev.VSAddin.Dialogs.PropertySheets
{
    internal class PropSheetCustomAction : PropSheetBase
    {
        public PropSheetCustomAction(string DefaultResourceFile, EnvDTE.ProjectItem ParentFeatureFolder, ElementInfo Element)
        {
            this.DefaultResourceFile = DefaultResourceFile;
            this.ParentFeatureFolder = ParentFeatureFolder;

            this.Title = new ResourceStringContainer(string.Empty, DefaultResourceFile, ParentFeatureFolder);
            this.Sequence = new ResourceStringContainer(string.Empty, DefaultResourceFile, ParentFeatureFolder);
            this.Description = new ResourceStringContainer(string.Empty, DefaultResourceFile, ParentFeatureFolder);

            this.ElementInfo = Element;
            this.ElementFileName = Element.ElementFileName;

            if (Element.XmlElementNode != null)
                this.PropXmlNode = Element.XmlElementNode;
        }

        [CategoryAttribute("Properties"), DescriptionAttribute("Title"), RefreshProperties(RefreshProperties.None), TypeConverter(typeof(ResourceExpandableObjectConverter))]
        public ResourceStringContainer Title
        {
            get;
            set;
        }

        [CategoryAttribute("Properties"), DescriptionAttribute("ID"), RefreshProperties(RefreshProperties.None)]
        public string Id
        {
            get;
            set;
        }

        [CategoryAttribute("Properties"), DescriptionAttribute("Sequence"), RefreshProperties(RefreshProperties.None), TypeConverter(typeof(ResourceExpandableObjectConverter))]
        public ResourceStringContainer Sequence
        {
            get;
            set;
        }

        [CategoryAttribute("Properties"), DescriptionAttribute("Location"), RefreshProperties(RefreshProperties.None)]
        public string Location
        {
            get;
            set;
        }

        [CategoryAttribute("Properties"), DescriptionAttribute("Description"), RefreshProperties(RefreshProperties.None), TypeConverter(typeof(ResourceExpandableObjectConverter))]
        public ResourceStringContainer Description
        {
            get;
            set;
        }

        [CategoryAttribute("Properties"), DescriptionAttribute("Group ID"), RefreshProperties(RefreshProperties.None)]
        public string GroupId
        {
            get;
            set;
        }

        public override string ToString()
        {
            string s = this.Title.GetValue(null);
            if (string.IsNullOrEmpty(s))
                s = this.ElementInfo.ElementName + this.ElementInfo.ID.ToString();

            return "<CustomAction> " + s;
        }

    }

}
